<script>
export default {
  name: "teacherRow",
  props: {
    item: {
      type: Object,
    }
  },
  methods: {
    call(mobile){
      uni.makePhoneCall({
        phoneNumber : mobile,
      })
    }
  }
}
</script>

<template>
  <view class="box" @tap="$xyfun.to('/pages/teacher/detail?id='+item.user_id)">

    <video class="avatar" :src="$xyfun.image(item.with.person_video)" v-if="item.with.person_video"></video>
    <image class="avatar" v-else :src="$xyfun.image(item.avatar)"></image>

    <view class="info" v-if="item.with">
      <view class="main">
        <view class="nickname">{{item.nickname}}老师</view>
        <view class="job">{{item.settled_type_for_list[0]}}</view>
        <view class="subject">{{item.give_lessons}}</view>
      </view>

      <view class="mobile" @click.stop="call(item.mobile)" v-if="item.mobile">电话：{{item.mobile}}<text class="yz-iconfont yz-dianhua"></text></view>

      <view class="base">
        <view class="education">{{item.with.school_name}}丨{{item.with.profession}}丨{{item.with.education}}</view>
        <view class="distance">{{item.with.unholiday_areas}}</view>
      </view>

      <view class="tags_gray">
        <view v-for="(val,idx) in item.with.tags_text">{{val}}</view>
      </view>

      <view class="tags_color">
        <view v-for="(val,idx) in item.with.teaching_method">{{val}}</view>
      </view>

      <view class="last_line">
        <view class="age">教龄:{{item.with.teacher_age}}年</view>
        <view class="star">评分：</view>
        <block v-if="item.star>=5">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
        </block>
        <block v-else-if="item.star>=4.5">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/half_star.png')"></image>
        </block>
        <block v-else-if="item.star>=4">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>

        </block>
        <block v-else-if="item.star>=3.5">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/half_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
        </block>
        <block v-else-if="item.star>=3">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
        </block>
        <block v-else-if="item.star>=2.5">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/half_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
        </block>
        <block v-else-if="item.star>=2">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
        </block>
        <block v-else-if="item.star>=1.5">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/half_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
        </block>
        <block v-else-if="item.star>=1">
          <image class="image" :src="$xyfun.image('/static/other/full_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
        </block>
        <block v-else-if="item.star>=0.5">
          <image class="image" :src="$xyfun.image('/static/other/half_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
        </block>
        <block v-else>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
          <image class="image" :src="$xyfun.image('/static/other/grey_star.png')"></image>
        </block>
        <view class="money">
          <view><text style="font-size: 20rpx;margin-right: 10rpx;">首次试课：</text></view>
          <view>￥<text>{{item.age_range_advise}}</text><text style="font-size: 16rpx;">/两小时</text></view>
        </view>
      </view>
    </view>
  </view>
</template>


<style scoped lang="scss">
.box{
  display: flex;
  padding-top: 32rpx;
  padding-left: 16rpx;
  border-bottom: 2rpx solid #eee;
  padding-bottom: 32rpx;
  box-sizing: border-box;
  .avatar{
    width: 155rpx;
    height: 155rpx;
    background-size:100% 100%;   /* 背景图片按比例缩放，覆盖整个元素 */
    border-radius: 8rpx;
  }
  .info{
    width:1rpx;
    flex-grow: 1;
    margin-left: 26rpx;

    .main{
      display: flex;
      width: 100%;
      align-items: center;
      margin-top: -12rpx;
      .nickname{
        font-weight: bold;
        font-size: 26rpx;
        margin-right: 10rpx;
      }
      .job{
        background: #ee9023;
        color: #ffffff;
        font-size: 16rpx;
        border-radius: 5rpx;
        padding: 2rpx 5rpx;
      }
      .subject{
        width: 1rpx;
        flex-grow: 1;
        text-align: right;
        font-size: 20rpx;
        margin-right: 22rpx;
      }
    }
    .mobile{
      color: grey;
      margin-top: 10rpx;
      font-size: 24rpx;
      text{
        color: $uni-color-warning;
        font-size: 32rpx;
        margin-left: 20rpx;
      }
    }

    .tags_gray{
      display: flex;
      view{
        font-size: 18rpx;
        margin-left: 10rpx;
        padding: 0 4rpx;
        background: #f5f5f5;
        &:nth-of-type(1){
          margin-left: 0;
        }
      }
    }
  }
  .base{
    margin-top: 10rpx;
    margin-bottom: 10rpx;
    display: flex;
    justify-content: space-between;
    line-height: 18rpx;
    .education{
      font-size: 18rpx;
    }

    .distance{
      float: right;
      font-size: 18rpx;
      color: #c9c9c9;
      margin-right: 24rpx;
    }
  }
  .tags_color{
    display: flex;
    margin-top: 6rpx;
    view{
      border: 2rpx solid #f2b26a;
      color: #f2b26a;
      font-size: 14rpx;
      margin-left: 10rpx;
      padding: 2rpx;
      border-radius: 5rpx;
      &:nth-of-type(1){
        margin-left: 0;
      }
      &:nth-of-type(2){
        border: 2rpx solid #a6c2ee;
        color: #a6c2ee;
      }
    }
  }

  .last_line{
    display: flex;
    align-items: center;
    .age{
      font-size: 22rpx;
    }
    .star{
      font-size: 20rpx;
      margin-left:46rpx;
    }
    .image{
      width: 20rpx;
      height: 20rpx;
    }
    .money{
      width: 1rpx;
      justify-content: right;
      flex-grow: 1;
      text-align: right;
      font-size: 16rpx;
      color: #F61D00;
      margin-top: -10rpx;
      padding-right: 20rpx;
    }
    .money text{
      font-weight: bold;
      font-size:30rpx;
      display: inline-block;
      position: relative;
      top: 5rpx;
    }
  }
}
</style>